<script setup>
import { expecteddetail, purchasedetail } from "@/services/reward";
import { ref } from "vue";
import { operation } from "@/utils/num.js";
import { formatPrice } from "@/utils/formatPrice";

const props = defineProps({
  id: {
    type: String,
    default: () => {
      return "";
    },
  },
  type: {
    type: String,
    default: () => {
      return "";
    },
  },
});

const type = ref(props.type);

const other = ref({});
const draws = ref({});
settleDetailfun();
async function settleDetailfun() {
  let res = null;
  if (props.type == 1) {
    res = await expecteddetail({
      id: props.id,
    });
  } else {
    res = await purchasedetail({
      id: props.id,
    });
  }

  // draws.value = res.data.draws;
  other.value = res.data;
}

const active = ref(0);

const list2 = ref([
  {
    title: "发起结算",
    desc: "2024-05-01",
  },
  {
    title: "结算中",
    desc: "2024-5-12",
  },
  {
    title: "结算成功",
    desc: "请耐心等待",
  },
]);
const operationfun = (a, b) => {
  let num = operation(a, b, 2, "subtract");
  return num;
};
</script>
<template>
  <view class="awaitClose">
    <!-- v-if="other.type == -1" -->
    <view class="awaitClose-top" v-if="other.other">
      <uni-steps
        :options="list2"
        active-color="#01ADA8"
        :active="active"
        direction="column"
      />
    </view>
    <!-- v-if="other.type == 1" -->
    <view class="awaitClose-bottom" v-if="type == 1">
      <view class="title">预估收益明细详情</view>
      <view class="card-item">
        <view class="item-name">创建时间</view>
        <view class="item-text">{{ other.create_time }}</view>
      </view>
      <view class="card-item">
        <view class="item-name">订单号</view>
        <view class="item-text">{{ other.relation_id }}</view>
      </view>

      <view class="card-item">
        <view class="item-name">数据编号</view>
        <view class="item-text">{{ other.id }}</view>
      </view>

      <view class="card-item">
        <view class="item-name">类型</view>
        <view class="item-text"
          >{{ other.class_text }}
          {{ other.type_text ? other.type_text : "" }}</view
        >
      </view>
      <view class="card-item">
        <view class="item-name">奖励来源</view>
        <view class="item-text">
          {{ other.fromUser ? other.fromUser.phone : "---" }}</view
        >
      </view>

      <view class="card-item">
        <view class="item-name">奖励金额</view>
        <view class="item-text item-text-add">{{
          formatPrice(other.money)
        }}</view>
      </view>

      <!-- <view class="card-item">
        <view class="item-name">状态</view>
        <view class="item-text">已出账</view>
      </view> -->

      <view class="card-item" v-if="other.other && other.other.actual_price">
        <view class="item-name">结算金额</view>
        <view class="item-text">{{
          formatPrice(
            other.other && other.other.actual_price
              ? other.other.actual_price
              : "---"
          )
        }}</view>
      </view>
      <view class="card-item" v-if="other.other && other.other.service_price">
        <view class="item-name">服务费</view>
        <view class="item-text">{{
          formatPrice(
            other.other && other.other.service_price
              ? other.other.service_price
              : "---"
          )
        }}</view>
      </view>
      <view class="card-item" v-if="other.other && other.other.tax_price">
        <view class="item-name">税费</view>
        <view class="item-text">{{
          formatPrice(
            other.other && other.other.tax_price ? other.other.tax_price : "---"
          )
        }}</view>
      </view>
      <!-- <view class="card-item" v-if="other.type == 1">
        <view class="item-name">奖励金额</view>
        <view class="item-text item-text-add">+{{ other.draw_balance }}</view>
      </view> -->
      <view class="card-item" v-if="other.type == -1">
        <view class="item-name">金额</view>
        <view class="item-text">-{{ formatPrice(other.money) }}</view>
      </view>
      <view class="card-item" v-if="other.type == 1">
        <view class="item-name">金额</view>
        <view class="item-text item-text-add"
          >+{{ formatPrice(other.money) }}</view
        >
      </view>
      <view class="card-item">
        <view class="item-name">奖励时间</view>
        <view class="item-text">
          {{ other.reward_time ? other.reward_time : "---" }}
        </view>
      </view>

      <view class="card-item">
        <view class="item-name">出账状态</view>
        <view class="item-text">
          待出账
        </view>
      </view>
    </view>

    <view class="awaitClose-bottom" v-if="type == 2">
      <view class="title">级差收益明细详情</view>
      <view class="card-item">
        <view class="item-name">创建时间</view>
        <view class="item-text">{{ other.create_time }}</view>
      </view>

      <view class="card-item">
        <view class="item-name">数据编号</view>
        <view class="item-text">{{ other.buyer_id }}</view>
      </view>

      <view class="card-item">
        <view class="item-name">订单状态</view>
        <view class="item-text"
          >{{ other.class_text }}
          {{ other.status_text ? other.status_text : "" }}</view
        >
      </view>
      <view class="card-item">
        <view class="item-name">奖励来源</view>
        <view class="item-text">
          {{ other.buyer ? other.buyer.phone : "---" }}</view
        >
      </view>

      <!-- <view class="card-item">
        <view class="item-name">状态</view>
        <view class="item-text">已出账</view>
      </view> -->

      <view class="card-item" v-if="other.other && other.other.actual_price">
        <view class="item-name">结算金额</view>
        <view class="item-text">{{
          formatPrice(
            other.other && other.other.actual_price
              ? other.other.actual_price
              : "---"
          )
        }}</view>
      </view>
      <view class="card-item" v-if="other.other && other.other.service_price">
        <view class="item-name">服务费</view>
        <view class="item-text">{{
          formatPrice(
            other.other && other.other.service_price
              ? other.other.service_price
              : "---"
          )
        }}</view>
      </view>
      <view class="card-item" v-if="other.other && other.other.tax_price">
        <view class="item-name">税费</view>
        <view class="item-text">{{
          formatPrice(
            other.other && other.other.tax_price ? other.other.tax_price : "---"
          )
        }}</view>
      </view>
      <!-- <view class="card-item" v-if="other.type == 1">
        <view class="item-name">奖励金额</view>
        <view class="item-text item-text-add">+{{ other.draw_balance }}</view>
      </view> -->
      <view class="card-item" v-if="other && other.pay_price">
        <view class="item-name">售出金额</view>
        <view class="item-text">{{
          formatPrice(other && other.pay_price ? other.pay_price : "---")
        }}</view>
      </view>

      <view class="card-item" v-if="other.purchase && other.purchase.order_id">
        <view class="item-name">采购金额</view>
        <view class="item-text">{{
          formatPrice(
            other.purchase && other.purchase.pay_price
              ? other.purchase.pay_price
              : "---"
          )
        }}</view>
      </view>
      <view class="card-item" v-if="other.ping_money">
        <view class="item-name">平级奖励</view>
        <view class="item-text">{{
          formatPrice(other.ping_money ? other.ping_money : "---")
        }}</view>
      </view>
      <view class="card-item" v-if="other.type == -1">
        <view class="item-name">金额</view>
        <view class="item-text">-{{ formatPrice(other.money) }}</view>
      </view>
      <view class="card-item">
        <view class="item-name">奖励金额</view>
        <view class="item-text item-text-add">{{
          formatPrice(other.stage_reward)
        }}</view>
      </view>
      <view class="card-item">
        <view class="item-name">下单时间</view>
        <view class="item-text">
          {{ other.pay_time ? other.pay_time : "---" }}
        </view>
      </view>
      <view class="card-item">
        <view class="item-name">订单号</view>
        <view class="item-text">{{ other.order_id }}</view>
      </view>

      <view class="card-item">
        <view class="item-name">出账状态</view>
        <view class="item-text">
          待出账
        </view>
      </view>
    </view>

    <!-- <view class="awaitClose-bottom" v-if="other.type === -1">
      <view class="title">余额明细详情</view>
      <view class="card-item">
        <view class="item-name">申请时间</view>
        <view class="item-text">{{ other.created_at }}</view>
      </view>
      <view class="card-item">
        <view class="item-name">数据编号</view>
        <view class="item-text">{{ other.draw_num }}</view>
      </view>

      <view class="card-item">
        <view class="item-name">类型</view>
        <view class="item-text"
          >{{ other.class_text }}
          {{ other.type_text ? "-" + other.type_text : "" }}
        </view>
      </view>
      <view class="card-item" v-if="other.account_type === 2">
        <view class="item-name">银行卡</view>
        <view class="item-text">
          {{
            (other.bank_name ? other.bank_name + "（" : "") +
            (other.bank_number ? other.bank_number + "）" : "")
          }}
        </view>
      </view>
      <view class="card-item">
        <view class="item-name" v-if="other.type == -1">结算金额</view>
        <view class="item-text item-text-color">-{{ other.apply_price }}</view>
      </view>
      <view class="card-item">
        <view class="item-name" v-if="other.type == 1">金额</view>
        <view class="item-text item-text-add">+{{ other.apply_price }}</view>
      </view>
      <view class="card-item">
        <view class="item-name">手续费</view>
        <view class="item-text">{{
          operationfun(other.apply_price, other.actual_price)
        }}</view>
      </view>
      <view class="card-item">
        <view class="item-name">实际金额</view>
        <view class="item-text">{{ other.actual_price }}</view>
      </view>
      <view class="card-item">
        <view class="item-name">结算状态</view>
        <view class="item-text">
          {{
            other.status == 0
              ? "申请中"
              : other.status == 1
              ? "结算中"
              : other.status == 2
              ? "结算成功"
              : other.status == 3
              ? "结算失败"
              : ""
          }}
        </view>
      </view>
      <view class="card-item">
        <view class="item-name">结算时间</view>
        <view class="item-text">
          {{
            other.status == 0
              ? other.created_at
              : other.status == 1
              ? other.updated_at
              : other.status == 2
              ? other.success_time
              : other.status == 3
              ? other.success_time
              : ""
          }}
        </view>
      </view>
    </view> -->
  </view>
</template>

<style lang="scss">
@import "awaitClose.scss";
</style>
